<?php

declare(strict_types=1);

namespace App\Api\Controller;

use App\Api\Middleware\ResponseMiddleware;
use App\Api\Service\NotifyService;
use Hyperf\HttpServer\Annotation\Controller;
use Hyperf\HttpServer\Annotation\Middlewares;
use Hyperf\HttpServer\Annotation\PostMapping;
use Psr\Http\Message\ResponseInterface;

#[Controller(prefix: 'api'), Middlewares([ResponseMiddleware::class])]
class NotifyController
{
    /**
     * 微信支付通知
     * @param NotifyService $service
     * @return ResponseInterface
     */
    #[PostMapping('notifies/wechat_pay')]
    public function wechatPay(NotifyService $service): ResponseInterface
    {
        $res = $service->wechatPay();
        logger()->info('test', ['res' => (string)$res->getBody()]);
        return $res;
    }
}
